package com.holly.unit.system.modular.user.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.holly.unit.system.modular.user.entity.*;
import com.holly.unit.system.modular.user.mapper.SysDataSynchronismMapper;
import com.holly.unit.system.modular.user.service.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * 数据同步记录实现类
 *
 * @author holly
 * @date 2020/11/21 15:04
 */
@Slf4j
@Service
public class SysDataSynchronismServiceImpl extends ServiceImpl<SysDataSynchronismMapper, SysDataSynchronism> implements SysDataSynchronismService {


    @Override
    public void edit(String dataType,Long dataMaxTime) {
        LambdaUpdateWrapper<SysDataSynchronism> updateWrapper = new LambdaUpdateWrapper<>();
        updateWrapper.set(SysDataSynchronism::getDataMaxTime,dataMaxTime);
        updateWrapper.eq(SysDataSynchronism::getDataType, dataType);
        this.update(updateWrapper);

    }


    @Override
    public Long detail(String dataType) {
        LambdaQueryWrapper<SysDataSynchronism> queryWrapper = new LambdaQueryWrapper<SysDataSynchronism>();
        queryWrapper.eq(SysDataSynchronism::getDataType, dataType);
        SysDataSynchronism sysDataSynchronism = this.baseMapper.selectOne(queryWrapper);
        return sysDataSynchronism.getDataMaxTime();
    }

}
